
// 封装 unirequest
const ajax = (obj)=>{
	// loading 
	uni.showLoading({
		title: '加载中'
	})
	
	return new Promise((resolve,reject)=>{
		uni.request({
			url:obj.url,
			method:obj.method?obj.method:"get",
			data:obj.data?obj.data:null,
			header:obj.header?obj.header:{
				"Content-Type":"application/json"
			},
			success(res) {
				resolve	(res.data)
				uni.hideLoading()
			},
			fail() {
				reject(res.data)
				uni.hideLoading()
			}
		})
		
	})
	
	
}

export default ajax



